﻿
Imports elpmis
Imports lpmsserv.lpmsservFunctions

Public Class lpmsctx
    Inherits context

    Private Shared Sub initialInternalVariables()
        insertSharedVariable("serverName", New const_bare_variable(typeDefination.string, applicationSign()))
    End Sub

    Private Shared Sub initialInternalFunctions()
        insertSharedFunction(New locstring())

        insertSharedFunction(New writeresponse())
        insertSharedFunction(New writeresponsebytes())
        insertSharedFunction(New sendresponsebytes())
        insertSharedFunction(New addresponseheader())
        insertSharedFunction(New overwriteresponseheader())
        insertSharedFunction(New removeresponseheader())
        insertSharedFunction(New setcontenttype())
        insertSharedFunction(New setcontenttypeOctetStream())
        insertSharedFunction(New setcontenttypeTextPlainUtf8())
        insertSharedFunction(New setcontenttypeTextHtmlUtf8())
        insertSharedFunction(New httpstatuscode())
        insertSharedFunction(New httpredirect())
        insertSharedFunction(New httprequestquery())
        insertSharedFunction(New httprequestcookie())
        insertSharedFunction(New httprequestip())
        insertSharedFunction(New httpresponsecookie())
        insertSharedFunction(New httprequestpath())
        insertSharedFunction(New requestformdata())
        insertSharedFunction(New setresponsecontentlength())

        insertSharedFunction(New xhtmlpagecreator())
        insertSharedFunction(New xhtmlpagetitle())
        insertSharedFunction(New xhtmlpagehtml())
        insertSharedFunction(New xhtmlpagehead())
        insertSharedFunction(New xhtmlpagebody())
        insertSharedFunction(New xhtmlpageinlinescript())
        insertSharedFunction(New xhtmlpageinlinestyle())
        insertSharedFunction(New xhtmlpagefooter())
        insertSharedFunction(New xhtmlpageaddinlinescript())
        insertSharedFunction(New xhtmlpageaddinlinestyle())
        insertSharedFunction(New xhtmlpageaddcsslink())
        insertSharedFunction(New xhtmlpageaddjslink())

        insertSharedFunction(New xmladdchild())
        insertSharedFunction(New xmlcreate())
        insertSharedFunction(New xmlrender())
        insertSharedFunction(New xmlattribute())
        insertSharedFunction(New xmltext())
        insertSharedFunction(New xmltextcreator())
        insertSharedFunction(New containercreator())

        insertSharedFunction(New storoomstructcreator())
        insertSharedFunction(New storoomstructread())
        insertSharedFunction(New storoomstructwrite())
        insertSharedFunction(New storoomlist())
        insertSharedFunction(New storoomsettalk())
        insertSharedFunction(New storoomread())
        insertSharedFunction(New storoomwrite())

        insertSharedFunction(New postercreator())
        insertSharedFunction(New posterdatasourcecreator())
        insertSharedFunction(New postersetdata())
        insertSharedFunction(New posterviewercreator())
        insertSharedFunction(New posterviewerdatasourcecreator())
        insertSharedFunction(New posterviewersetdata())

        insertSharedFunction(New jsajaxresponse())
        insertSharedFunction(New jsajaxcall())
        insertSharedFunction(New jschangeInnerHtmlById())
        insertSharedFunction(New jsInterval())
        insertSharedFunction(New jschangeValue())
        insertSharedFunction(New jsnumbercheck())
        insertSharedFunction(New jsnumberreplace2())
        insertSharedFunction(New jsvisibilityById())
        insertSharedFunction(New jsshowById())
        insertSharedFunction(New jshideById())

        insertSharedFunction(New generatecssrequestlink())
        insertSharedFunction(New generatestaticrequestlink())

        insertSharedFunction(New configreader2())
        insertSharedFunction(New configlistreader2())

        insertSharedFunction(New formdataname())
        insertSharedFunction(New formdatafilename())
        insertSharedFunction(New formdatacontent())
        insertSharedFunction(New formdataread())
        insertSharedFunction(New formdatacontainsfile())
        insertSharedFunction(New formdatatempfile())
    End Sub

    Shared Sub New()
        initialInternalVariables()
        initialInternalFunctions()
    End Sub

    'this is a caller function to let others call shared lpmsctx.new()
    Public Shared Sub SharedNew()
    End Sub

    'since lpmsapp called lpmsctx.contextpool() before context call it, so the shared function will initialize cp
    Public Shared Shadows Function contextpool() As iContextpool
        If cp Is Nothing Then
            cp = New lpmsctxpool_t()
        End If
        Return context.contextpool()
    End Function
End Class

Public Class lpmsctxpool_t
    Inherits contextpool_t

    Protected Overrides Function create() As context
        Return New lpmsctx()
    End Function
End Class
